<?php
/**
 * @author sanketsp
 * Annotation class: Holds annotations made by the instructor.
 */
Class Annotation {
	/**
	 * Constructor
	 * @param $id ID of the Annotation
	 */
	function __construct($id) {
		$query = mysql_query("SELECT * FROM `annotation` WHERE `id` = '$id';") or die(mysql_error());
		$result = mysql_fetch_object($query);
		if($result) {
			foreach($result as $key=>$value) {
				$this->$key = $value;
				if($value == '') {
					$this->$key = 'NULL';
				}
			}
		}
	}
	/**
	 * Update this annotation
	 */
	public function updateAnnotation() {
		$query = mysql_query("UPDATE `annotation` SET `date`='$this->date',`instructor_id`='$this->instructor_id',`course_id`=$this->course_id,`group_id`=$this->group_id,`student_id`=$this->student_id,`comment`='$this->comment' WHERE `id` = '$this->id'") or die(mysql_error());
		return true;
	}
	/**
	 * Removes a specific Annotation permanently
	 */
	public function remove() {
		mysql_query("UPDATE `annotation` SET `instructor_id` = NULL  WHERE `id` = '$this->id'") or die(mysql_error());
		return true;
	}
}